﻿using System;

namespace WiMo.Games
{
    public struct Size
    {
        public Size(int width, int height)
        {
            _width = width;
            _height = height;
        }

        public static Size Zero
        {
            get { return new Size(0, 0); }
        }

        public Size(float width, float height)
        {
            _width =  Convert.ToInt32(width);
            _height = Convert.ToInt32(height);
        }

        private int _width;
        private int _height;

        public int Width
        {
            get { return _width; }
            set { _width = value; }
        }

        public int Height
        {
            get { return _height; }
            set { _height = value; }
        }

        public static bool operator !=(Size s1, Size s2)
        {
            return (s1.Width != s2.Width || s1.Height != s2.Height);
        }

        public static bool operator ==(Size s1, Size s2)
        {
            return !(s1 != s2);
        }

        public static Size operator /(Size left, int divisor)
        {
            return new Size(left._width / divisor, left._height / divisor);
        }

        public override bool Equals(object obj)
        {
            if (obj is Size)
            {
                var size = (Size)obj;
                return this == size;
            }

            return false;
        }

        public override int GetHashCode()
        {
            return _height * _width;
        }

    }
}
